package com.hgxd.mc.utils;

public class ByteToHexStrUtil {

    public static String bytesToHexString(byte[] bs) {
        StringBuffer sb = new StringBuffer();
        if (bs == null) {
            return null;
        }

        for (int i = 0; i < bs.length; i++) {
            // Integer.toHexString(int)来转换成16进制字符串
            String hex = Integer.toHexString(bs[i] & 0xFF);
            if (hex.length() == 1) {
                hex = '0' + hex;
            }
            sb.append(hex.toUpperCase()); // 将小写字母转化为大写
        }

        return sb.toString();
    }
}
